package com.hailin.pigapi.common;

/**
 * 定义的统一返回值
 * @param <T>
 */
public class Result<T> {
    private boolean success;
    private T data;
    private String message;

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static Result create(){
        return new Result<>();
    }

    public Result(){

    }

    public Result(boolean success, T data, String message) {
        this.success = success;
        this.data = data;
        this.message = message;
    }

    public Result success(T data){
        return new Result(true,data,null);
    }

    public Result success(){
        return new Result(true,null,null);
    }

    public Result fail(String message){
        return new Result(false,null,message);
    }
}
